console.log('@config begin ' + new Date().Format('mm:ss'));
import request from '@utils/request';
//import { getToken } from '@utils/auth';
import router from '@router/index';
console.log('@config after import', request + new Date().Format('mm:ss'));
request.setInjector(({ headers }) => {
  let token = sessionStorage.getItem('token');
  console.log('@config setInject' + new Date().Format('mm:ss'));
  token && (headers.token = token)
});

request.setReceiver(({ response }) => {
  if (response && response.status === 401) {
    router.replace('/login');
  }
});

window.request = request;
